Skip to content

implement feature of Personalized Recipe and Meal Recommendation using AI#78

Open
sahoo-tech wants to merge 1 commit intoPranjal6955:mainfrom
sahoo-tech:main
Open

implement feature of Personalized Recipe and Meal Recommendation using AI#78
sahoo-tech wants to merge 1 commit intoPranjal6955:mainfrom
sahoo-tech:main

Conversation

@sahoo-tech
Copy link
Copy Markdown

@sahoo-tech sahoo-tech commented Feb 28, 2026

User description

🍲 Feature: Personalized AI Recipe Recommendations

📝 Description

This PR introduces the new "Personalized Recipes" feature to NutriLens, transitioning the app from a purely tracking tool to a proactive nutrition assistant.

It leverages the existing Gemini AI integration to generate tailored meal recommendations based on a user's recent scan history, empowering users to make better dietary choices to hit their nutritional goals.

🛠️ Changes Made

  • Backend:
    • Added a new recommendations.js route to handle AI prompt generation and fetching data from the Gemini API.
    • Implemented logic to analyze a user's recent scan history to formulate context-aware AI prompts for meal suggestions.
  • Frontend:
    • Created a new RecipeRecommendations.tsx component to display the suggested recipes in a clean, user-friendly card layout.
    • Added a new dedicated Recipes.tsx page for users to browse their recommendations.
    • Updated Navbar.tsx to include navigation to the new Recipes page.
    • Added robust API calls in api.ts to interface with the new backend recommendation endpoint.
    • Updated App.tsx routing to accommodate the new views.

📸 Screenshots / UX Flow

(Please drag and drop screenshots or a screen recording of the new Recipes page here)

🔍 Testing Steps

  1. Navigate to the new /recipes route (or click "Recipes" in the Navbar).
  2. Ensure the loading state displays correctly while the API is fetching.
  3. Verify that 3 recipe cards are generated.
  4. Check if the generated recipes logically align with previous scans for this user (e.g., if previous meals were high carb, recipes should theoretically balance that out).
  5. Verify responsive design on mobile and desktop views.

🛑 Known Issues / Future Improvements

  • Currently, recommendations are generated on-the-fly, which might take a few seconds due to Gemini API latency.
  • Next Steps: Consider caching recommendations or running a background cron job to pre-generate daily recipes to improve perceived performance.

CodeAnt-AI Description

Add AI-powered personalized recipe recommendations and UI to browse them

What Changed

  • Users can request personalized recipe suggestions generated from their day's logged meals and remaining nutrient targets; the app returns up to 3 structured recipes (title, prep time, calories/macros, ingredients, instructions, tags).
  • New "Recipes" page and a Recipes button in the navbar provide a dedicated view; recipe cards show prep time, calories/macros, tags, expandable ingredients and step-by-step instructions, with retry and empty-state handling.
  • Home now surfaces the recommendations section so users see suggestions on the main screen; the frontend calls a new recommendations endpoint to fetch recipe lists.
  • Backend adds an endpoint that aggregates today's logged meals, computes remaining daily macros against targets, prompts the AI to generate three practical recipes, and returns parsing-safe JSON plus daily totals and remaining macros; it handles API key rate limits and parse errors with clear error responses.

Impact

✅ Personalized meal suggestions based on today's logs
✅ Easier discovery of practical recipes from the main screen and navbar
✅ Clear retry and empty-state feedback when recommendations are unavailable

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 28, 2026

@sahoo-tech is attempting to deploy a commit to the pranjal6955's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Feb 28, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@github-actions
Copy link
Copy Markdown

Hi @sahoo-tech! 👋 Thank you for your contribution!

We really appreciate you taking the time to improve NutriLens. Our team will review your Pull Request shortly.

📚 New here? Please check out our Readme.md for contribution guidelines!


🌟 Support us! If you find this project helpful, please consider giving us a star on GitHub! It helps more developers discover the project. Star NutriLens

@codeant-ai codeant-ai bot added the size:L This PR changes 100-499 lines, ignoring generated files label Feb 28, 2026
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Feb 28, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Cross-user data exposure
    The recommendations handler queries Meal.find({ createdAt: { $gte: startOfDay } }) without filtering by a user identifier. That will aggregate and return meals from all users for "today", causing potential data leakage across users and incorrect recommendations calculated from unrelated users' meals.

  • Unprotected endpoint
    The new recommendations route is mounted without authentication or route-level authorization (it is required via app.use('/api', recommendationsRoutes)). This exposes AI recommendation generation and meal data to unauthenticated callers and increases risk of abuse (cost/rate limit exhaustion, scraping).

  • Public route exposing recommendations
    The new Recipes page is added as a public page and mounts RecipeRecommendations. If the recommendation API is not protected, the new route creates an easy public entrypoint to call backend AI endpoints (possible abuse, cost, and privacy leaks). Confirm intended access control for this page and whether it should require authentication.

  • Auth / Data exposure risk
    Rendering RecipeRecommendations on the public Home page may trigger calls to backend recommendation/history endpoints. If those backend endpoints are unprotected, anonymous visitors could retrieve or trigger user-specific analysis or consume quota/costs. Verify whether the recommendations component calls protected APIs and whether it should be gated by auth or rate-limited.

  • Frontend/backend auth mismatch
    The frontend requires navigating to a protected /analysis view, but backend endpoints used for analysis/history are mounted unprotected (analyze routes are registered with app.use('/api', uploadLimiter, analyzeRoutes)). This inconsistency can create a confusing UX and a security gap: users may be blocked client-side while backend endpoints remain callable without authentication.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Feb 28, 2026

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request frontend size/l size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants